﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Media;

namespace kb_24_the_game
{
    class EndCredits
    {
        #region Variabelen Declaratie

        ContentManager content;
        Texture2D videoTexture;
        Video video;
        VideoPlayer player;
        bool eerstekeer = true;

        #endregion Variabelen Declaratie

        public EndCredits(ContentManager content)
        {
            this.content = content;
            Load();
        }

        public void Load()
        {
            video = content.Load<Video>(@"Achtergronden/Credits");
            player = new VideoPlayer();
        }

        public bool Update(GameTime gametime)
        {
            if (eerstekeer == true)
            {
                player.Play(video);
                eerstekeer = false;
            }
            if (player.State == MediaState.Stopped)
            {
                eerstekeer = true;
                return true;
            }
            else
            {
                return false;
            }
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            if (player.State != MediaState.Stopped)
            {
                videoTexture = player.GetTexture();
            }
            if (videoTexture != null)
            {
                spriteBatch.Draw(videoTexture,new Rectangle(0,0, video.Width, video.Height), Color.White);
            }
        }
    }
}
